
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import gui.BotGui;


public class RepeatNameCheck {
	public static void main(String[] args){
		File demo = new File("c:\\Users\\Jamison\\Documents\\PopulationInfo\\MarylandCensus.txt");
		File data = new File("c:\\Users\\Jamison\\Documents\\PopulationInfo\\MarylandData.txt");
		
//		checkCensus(demo);
		checkData(data);
	}
	
	public static void checkCensus(File file){
		try{
			Set<String> hash = new HashSet<String>();
			BufferedReader reader = new BufferedReader(new FileReader(file));
			String line = null;
			while ((line = reader.readLine()) != null){
				String test[] = line.split(" ;&: ");
				String name = test[0];
				boolean result = hash.add(name);
				if (!result){
					System.out.println(name);
				}
			}
		} 
		catch (FileNotFoundException e){
			e.printStackTrace();
		} 
		catch (IOException e){
			e.printStackTrace();
		}
	}
	
	public static void checkData(File file){
		try{
			Set<String> hash = new HashSet<String>();
			BufferedReader reader = new BufferedReader(new FileReader(file));
			String line = null;
			while ((line = reader.readLine()) != null){
				String test[] = line.split(" ;&: ");
				String name = test[1];
				boolean result = hash.add(name);
				if (!result){
					System.out.println(name);
				}
			}
		} 
		catch (FileNotFoundException e){
			e.printStackTrace();
		} 
		catch (IOException e){
			e.printStackTrace();
		}
	}
}
